/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package football;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Herbert
 */
@Entity
@Table(name = "SEKTOR")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sektor.findAll", query = "SELECT s FROM Sektor s"),
    @NamedQuery(name = "Sektor.findByIdSektor", query = "SELECT s FROM Sektor s WHERE s.idSektor = :idSektor"),
    @NamedQuery(name = "Sektor.findByNameSektor", query = "SELECT s FROM Sektor s WHERE s.nameSektor = :nameSektor"),
    @NamedQuery(name = "Sektor.findByAnzahl", query = "SELECT s FROM Sektor s WHERE s.anzahl = :anzahl")})
public class Sektor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_SEKTOR")
    private Integer idSektor;
    @Size(max = 200)
    @Column(name = "NAME_SEKTOR")
    private String nameSektor;
    @Column(name = "ANZAHL")
    private Integer anzahl;
    @JoinColumn(name = "ID_STADION", referencedColumnName = "ID_STADION")
    @ManyToOne(optional = false)
    private Stadion idStadion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSektor")
    private Collection<Sitzplatz> sitzplatzCollection;

    public Sektor() {
    }

    public Sektor(Integer idSektor) {
        this.idSektor = idSektor;
    }

    public Integer getIdSektor() {
        return idSektor;
    }

    public void setIdSektor(Integer idSektor) {
        this.idSektor = idSektor;
    }

    public String getNameSektor() {
        return nameSektor;
    }

    public void setNameSektor(String nameSektor) {
        this.nameSektor = nameSektor;
    }

    public Integer getAnzahl() {
        return anzahl;
    }

    public void setAnzahl(Integer anzahl) {
        this.anzahl = anzahl;
    }

    public Stadion getIdStadion() {
        return idStadion;
    }

    public void setIdStadion(Stadion idStadion) {
        this.idStadion = idStadion;
    }

    @XmlTransient
    public Collection<Sitzplatz> getSitzplatzCollection() {
        return sitzplatzCollection;
    }

    public void setSitzplatzCollection(Collection<Sitzplatz> sitzplatzCollection) {
        this.sitzplatzCollection = sitzplatzCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSektor != null ? idSektor.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sektor)) {
            return false;
        }
        Sektor other = (Sektor) object;
        if ((this.idSektor == null && other.idSektor != null) || (this.idSektor != null && !this.idSektor.equals(other.idSektor))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "football.Sektor[ idSektor=" + idSektor + " ]";
    }
    
}
